package com.ft.turorial.spring.boot.repository;

import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;

import com.ft.turorial.spring.boot.domain.User;

@CacheConfig(cacheNames = "users")
public interface UserRepository extends JpaRepository<User, Long>{
	
	@Cacheable(value="user",key="#p0")
	User findByName(String name);
	
	@SuppressWarnings("unchecked")
	@CachePut(value="user",key="#p0.name")
	User save(User user);
}
